<template>
	<!-- 发起人 -->
	<promoter v-if="nodeConfig.type == 0" v-model="nodeConfig" :disabled="disabled"></promoter>

	<!-- 审批人 -->
	<approver v-if="nodeConfig.type == 1" v-model="nodeConfig" :disabled="disabled"></approver>

	<!-- 抄送人 -->
	<send v-if="nodeConfig.type == 2" v-model="nodeConfig" :disabled="disabled"></send>

	<!-- 分支 -->
	<branch v-if="nodeConfig.type == 4" v-model="nodeConfig" :disabled="disabled">
		<template #default="slot">
			<node-wrap v-if="slot.node" v-model="slot.node.childNode" :disabled="disabled"></node-wrap>
		</template>
	</branch>

	<!-- 子流程 -->
	<sub-process v-if="nodeConfig.type == 5" v-model="nodeConfig" :disabled="disabled"></sub-process>

	<!-- 延时处理 -->
	<delay-process v-if="nodeConfig.type == 6" v-model="nodeConfig" :disabled="disabled"></delay-process>

	<!-- 触发器 -->
	<trigger v-if="nodeConfig.type == 7" v-model="nodeConfig" :disabled="disabled"></trigger>

	<!-- 并行分支 -->
	<parallel-branch v-if="nodeConfig.type == 8" v-model="nodeConfig" :disabled="disabled">
		<template #default="slot">
			<node-wrap v-if="slot.node" v-model="slot.node.childNode" :disabled="disabled"></node-wrap>
		</template>
	</parallel-branch>

	<!-- 包容分支 -->
	<merge-branch v-if="nodeConfig.type == 9" v-model="nodeConfig" :disabled="disabled">
		<template #default="slot">
			<node-wrap v-if="slot.node" v-model="slot.node.childNode" :disabled="disabled"></node-wrap>
		</template>
	</merge-branch>

	<node-wrap v-if="nodeConfig.childNode" v-model="nodeConfig.childNode" :disabled="disabled"></node-wrap>
</template>

<script>
import approver from './nodes/approver'
import promoter from './nodes/promoter'
import branch from './nodes/branch'
import parallelBranch from './nodes/parallelBranch'
import mergeBranch from './nodes/mergeBranch'
import send from './nodes/send'
import delayProcess from './nodes/delayProcess'
import trigger from './nodes/trigger'
import subProcess from './nodes/subProcess'

export default {
	components: {
		approver,
		promoter,
		branch,
		send,
		delayProcess,
		trigger,
		subProcess,
		parallelBranch,
		mergeBranch
	},
	props: {
		modelValue: { type: Object, default: () => {} },
		disabled: {
			type: Boolean,
			default: false
		}
	},
	data() {
		return {
			nodeConfig: this.modelValue
		}
	},
	watch: {
		modelValue(val) {
			this.nodeConfig = val
		},
		nodeConfig(val) {
			this.$emit('update:modelValue', val)
		}
	},
	methods: {}
}
</script>

<style></style>
